home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / SText.tcl.z / SText.tcl
Encoding:
Text File  |  1999-01-26  |  3.2 KB  |  137 lines

  1. # SText.tcl --
  2. #
  3. #    This file implements Scrolled Text widgets
  4. #
  5. # Copyright (c) 1996, Expert Interface Technologies
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10.  
  11.  
  12.  
  13. tixWidgetClass tixScrolledText {
  14.     -classname TixScrolledText
  15.     -superclass tixScrolledWidget
  16.     -method {
  17.     }
  18.     -flag {
  19.     }
  20.     -static {
  21.     }
  22.     -configspec {
  23.     }
  24.     -default {
  25.     {.scrollbar            both}
  26.     {*borderWidth            1}
  27.     {*text.background        #c3c3c3}
  28.     {*text.highlightBackground    #d9d9d9}
  29.     {*text.relief            sunken}
  30.     {*text.takeFocus        1}
  31.     {*Scrollbar.background        #d9d9d9}
  32.     {*Scrollbar.relief        sunken}
  33.     {*Scrollbar.troughColor        #c3c3c3}
  34.     {*Scrollbar.takeFocus        0}
  35.     {*Scrollbar.width        15}
  36.     }
  37.     -forcecall {
  38.     -scrollbar
  39.     }
  40. }
  41.  
  42. proc tixScrolledText:ConstructWidget {w} {
  43.     upvar #0 $w data
  44.  
  45.     tixChainMethod $w ConstructWidget
  46.  
  47.     set data(w:text) \
  48.     [text $w.text]
  49.     set data(w:hsb) \
  50.     [scrollbar $w.hsb -orient horizontal]
  51.     set data(w:vsb) \
  52.     [scrollbar $w.vsb -orient vertical]
  53.  
  54.     set data(pw:client) $data(w:text)
  55. }
  56.  
  57. proc tixScrolledText:SetBindings {w} {
  58.     upvar #0 $w data
  59.  
  60.     tixChainMethod $w SetBindings
  61.  
  62.     $data(w:text) config \
  63.     -xscrollcommand "tixScrolledText:XScroll $w"\
  64.     -yscrollcommand "tixScrolledText:YScroll $w"
  65.  
  66.     $data(w:hsb) config -command "$data(w:text) xview"
  67.     $data(w:vsb) config -command "$data(w:text) yview"
  68. }
  69.  
  70. #----------------------------------------------------------------------
  71. #
  72. #        option configs
  73. #----------------------------------------------------------------------
  74. proc tixScrolledText:config-takefocus {w value} {
  75.     upvar #0 $w data
  76.   
  77.     $data(w:text) config -takefocus $value
  78. }    
  79.  
  80. proc tixScrolledText:config-scrollbar {w value} {
  81.     upvar #0 $w data
  82.   
  83.     if {[string match "auto*" $value]} {
  84.     # There is a bug in TK that prevents the "auto" from operating
  85.     # properly - sometimes you'd get "flashing" effect when
  86.     # scrollbars keep apprearing and going away.
  87.     set value "both"
  88.     }
  89.     set data(-scrollbar) $value
  90.  
  91.     tixChainMethod $w config-scrollbar $value
  92.  
  93.     return $value
  94. }    
  95.  
  96. #----------------------------------------------------------------------
  97. #
  98. #        Widget commands
  99. #----------------------------------------------------------------------
  100.  
  101.  
  102. #----------------------------------------------------------------------
  103. #
  104. #        Private Methods
  105. #----------------------------------------------------------------------
  106.  
  107. #----------------------------------------------------------------------
  108. # virtual functions to query the client window's scroll requirement
  109. #----------------------------------------------------------------------
  110. proc tixScrolledText:GeometryInfo {w mW mH} {
  111.     upvar #0 $w data
  112.  
  113.     return [list "$data(x,first) $data(x,last)" "$data(y,first) $data(y,last)"]
  114. }
  115.  
  116. proc tixScrolledText:XScroll {w first last} {
  117.     upvar #0 $w data
  118.  
  119.     set data(x,first) $first
  120.     set data(x,last)  $last
  121.  
  122.     $data(w:hsb) set $first $last
  123.  
  124.     tixWidgetDoWhenIdle tixScrolledWidget:Configure $w
  125. }
  126.  
  127. proc tixScrolledText:YScroll {w first last} {
  128.     upvar #0 $w data
  129.  
  130.     set data(y,first) $first
  131.     set data(y,last)  $last
  132.     
  133.     $data(w:vsb) set $first $last
  134.  
  135.     tixWidgetDoWhenIdle tixScrolledWidget:Configure $w
  136. }
  137.